

public class Date {
    public int year;
    public int month;
    public int day;

    public void setDate(int year, int month, int day){
        //this代表当前对象的引用  谁调用这个方法this就是谁  date调用这个方法 那么this就是date
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printDate(){
        System.out.println("年："+year+"月："+month+"日："+day);
    }

    public static void main(String[] args) {
        Date date = new Date();
        date.setDate(2008, 8, 8);
        date.printDate();

        System.out.println();

        Date date1 = new Date();
        date1.setDate(2007, 6, 5);
        date1.printDate();
    }
}
